package recursion;

/*
 * 认识递归：方法调用自己
 * */
public class Demo1 {
    public static void main(String[] args) {
        System.out.println(sum(10));
        System.out.println(print(5));
    }

    private static int print(int i) {
        if (i == 1)
            return 1;
        return i*print(i-1);
    }

    public static int sum(int n) {
        if (n == 1)
            return 1;
        return n + sum(n - 1);
    }
}

